#!/usr/bin/env python
#coding=utf-8

import wx

class myframe(wx.Frame):
    
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,size=(300,200))
        try:        
            self.initui()
            self.objbind()
        except Exception,ex:
            print ex
    
    def initui(self):
        label1=wx.StaticText(self,-1,u'RTX 分机号：')
        label2=wx.StaticText(self,-1,u'密码：')
        self.txtbox1=wx.TextCtrl(self,-1,'')
        self.txtbox2=wx.TextCtrl(self,-1,'')
        gsizer=wx.FlexGridSizer(2,2,5,5)
        gsizer.Add(label1,0,0,5)
        gsizer.Add(self.txtbox1,0,0,5)
        gsizer.Add(label2,0,0,5)        
        gsizer.Add(self.txtbox2,0,0,5)
        
        self.panel1=wx.Panel(self,-1)        
        labeladdress=wx.StaticText(self.panel1,-1,u'地址')
        self.txtboxaddress=wx.TextCtrl(self.panel1,-1,'')
        hbox1=wx.BoxSizer(wx.HORIZONTAL)
        hbox1.Add(labeladdress,-1,wx.ALL,5)
        hbox1.Add(self.txtboxaddress,0,wx.ALL,5)
        self.panel1.SetSizer(hbox1)
        
        self.btnsetup=wx.Button(self,-1,u'设置>')
        self.btnlogin=wx.Button(self,-1,u'登录')
        hbox2=wx.BoxSizer(wx.HORIZONTAL)
        hbox2.Add(self.btnsetup)
        hbox2.Add(self.btnlogin)
        
        vbox=wx.BoxSizer(wx.VERTICAL)
        vbox.Add(gsizer)
        vbox.Add(self.panel1)
        vbox.Add(hbox2)
        self.SetSizer(vbox)
    
    def objbind(self):
        self.Bind(wx.EVT_BUTTON,self.on_click_setup,self.btnsetup)
        
    def on_click_setup(self,evt):
        if self.btnsetup.GetLabel()=='设置>'.decode('utf-8'):
            self.panel1.Hide()
            self.btnsetup.SetLabel(u'设置<')
        else:
            self.panel1.Show()
            self.btnsetup.SetLabel(u'设置>')
        self.Layout()    
    
def main():
    app=wx.App()
    frame=myframe(None,-1,'test')
    frame.Show()
    app.MainLoop()
    
if __name__ == '__main__':
    main()
    
